package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"jd/userapi/internal/config"
	"jd/userapi/internal/middleware"
	"jd/userrpc/userrpcclient"
)

type ServiceContext struct {
	Config          config.Config
	UserRpc         userrpcclient.Userrpc
	LoginMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:          c,
		UserRpc:         userrpcclient.NewUserrpc(zrpc.MustNewClient(c.UserRpc)),
		LoginMiddleware: middleware.NewLoginMiddleware().Handle,
	}
}
